<!DOCTYPE html>
<html>
<head>
    <title>{{ article.title }} - 垃圾分类科普知识</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }
        
        .container {
            max-width: 800px;
            margin: 0 auto;
        }
        
        .header {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            padding: 20px 30px;
            margin-bottom: 30px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
        }
        
        .header h1 {
            color: #2d3748;
            font-size: 28px;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 12px;
        }
        
        .header-actions {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
        }
        
        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 10px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            text-decoration: none;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }
        
        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
        }
        
        .btn-secondary {
            background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
            color: white;
        }
        
        .btn-secondary:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(107, 114, 128, 0.3);
        }
        
        .btn-success {
            background: linear-gradient(135deg, #10b981 0%, #059669 100%);
            color: white;
        }
        
        .btn-success:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
        }
        
        .article-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            padding: 40px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            animation: slideUp 0.6s ease-out;
        }
        
        @keyframes slideUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .article-header {
            text-align: center;
            margin-bottom: 30px;
            padding-bottom: 20px;
            border-bottom: 2px solid #e5e7eb;
        }
        
        .article-title {
            font-size: 32px;
            font-weight: 700;
            color: #2d3748;
            margin-bottom: 15px;
            line-height: 1.3;
        }
        
        .article-meta {
            display: flex;
            justify-content: center;
            gap: 20px;
            flex-wrap: wrap;
            margin-bottom: 15px;
        }
        
        .meta-item {
            display: flex;
            align-items: center;
            gap: 6px;
            color: #6b7280;
            font-size: 14px;
        }
        
        .category-badge {
            padding: 6px 16px;
            border-radius: 25px;
            font-size: 14px;
            font-weight: 600;
            color: white;
        }
        
        .category-recyclable {
            background: linear-gradient(135deg, #10b981 0%, #059669 100%);
        }
        
        .category-harmful {
            background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
        }
        
        .category-kitchen {
            background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
        }
        
        .category-other {
            background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
        }
        
        .category-knowledge {
            background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
        }
        
        .category-environment {
            background: linear-gradient(135deg, #059669 0%, #047857 100%);
        }
        
        .article-image {
            width: 100%;
            max-width: 600px;
            height: auto;
            border-radius: 16px;
            margin: 20px auto;
            display: block;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
        }
        
        .article-content {
            font-size: 16px;
            line-height: 1.8;
            color: #374151;
            margin-bottom: 30px;
        }
        
        .article-content p {
            margin-bottom: 16px;
        }
        
        .article-content h2 {
            font-size: 24px;
            font-weight: 600;
            color: #2d3748;
            margin: 30px 0 16px 0;
            padding-bottom: 8px;
            border-bottom: 2px solid #e5e7eb;
        }
        
        .article-content h3 {
            font-size: 20px;
            font-weight: 600;
            color: #374151;
            margin: 24px 0 12px 0;
        }
        
        .article-content ul,
        .article-content ol {
            margin: 16px 0;
            padding-left: 24px;
        }
        
        .article-content li {
            margin-bottom: 8px;
        }
        
        .article-footer {
            background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
            border-radius: 16px;
            padding: 20px;
            text-align: center;
            border: 1px solid #e5e7eb;
        }
        
        .article-footer h4 {
            color: #374151;
            margin-bottom: 10px;
            font-size: 16px;
        }
        
        .footer-meta {
            display: flex;
            justify-content: center;
            gap: 30px;
            flex-wrap: wrap;
            color: #6b7280;
            font-size: 14px;
        }
        
        .back-to-list {
            text-align: center;
            margin-top: 30px;
        }
        
        @media (max-width: 768px) {
            .header {
                flex-direction: column;
                gap: 16px;
                text-align: center;
            }
            
            .header-actions {
                justify-content: center;
            }
            
            .article-card {
                padding: 20px;
            }
            
            .article-title {
                font-size: 24px;
            }
            
            .article-meta {
                flex-direction: column;
                gap: 10px;
            }
            
            .footer-meta {
                flex-direction: column;
                gap: 10px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>📖 科普文章详情</h1>
            <div class="header-actions">
                <a href="/knowledge" class="btn btn-secondary">⬅️ 返回列表</a>
                <a href="/" class="btn btn-primary">🏠 返回首页</a>
                {% if session.user_id %}
                    <a href="/logout" class="btn btn-success">🚪 注销</a>
                {% else %}
                    <a href="/login" class="btn btn-success">🔑 登录</a>
                {% endif %}
            </div>
        </header>
        
        <div class="article-card">
            <div class="article-header">
                <h1 class="article-title">{{ article.title }}</h1>
                
                <div class="article-meta">
                    <div class="meta-item">
                        <span>👤</span>
                        <span>{{ article.author }}</span>
                    </div>
                    <div class="meta-item">
                        <span>📅</span>
                        <span>{{ article.created_at.strftime('%Y年%m月%d日 %H:%M') }}</span>
                    </div>
                    <div class="meta-item">
                        <span>👁️</span>
                        <span>{{ article.view_count }} 次浏览</span>
                    </div>
                </div>
                
                <span class="category-badge 
                    {% if article.category == '可回收垃圾' %}category-recyclable
                    {% elif article.category == '有害垃圾' %}category-harmful
                    {% elif article.category == '厨余垃圾' %}category-kitchen
                    {% elif article.category == '其他垃圾' %}category-other
                    {% elif article.category == '环保知识' %}category-environment
                    {% else %}category-knowledge{% endif %}">
                    {{ article.category }}
                </span>
            </div>
            
            {% if article.image_url %}
                <img src="{{ article.image_url }}" alt="{{ article.title }}" class="article-image" onerror="this.style.display='none'">
            {% endif %}
            
            <div class="article-content">
                {% for paragraph in article.content.split('\n') %}
                    {% if paragraph.strip() %}
                        <p>{{ paragraph }}</p>
                    {% endif %}
                {% endfor %}
            </div>
            
            <div class="article-footer">
                <h4>📊 文章信息</h4>
                <div class="footer-meta">
                    <span>📝 创建时间：{{ article.created_at.strftime('%Y-%m-%d %H:%M:%S') }}</span>
                    <span>🔄 更新时间：{{ article.updated_at.strftime('%Y-%m-%d %H:%M:%S') }}</span>
                    <span>👁️ 浏览次数：{{ article.view_count }}</span>
                </div>
            </div>
        </div>
        
        <div class="back-to-list">
            <a href="/knowledge" class="btn btn-primary">📚 查看更多科普文章</a>
        </div>
    </div>
</body>
</html>